package com.atguigu.gmall.search.controller;

import com.atguigu.gmall.common.bean.ResponseVo;
import com.atguigu.gmall.search.pojo.SearchParamVo;

import com.atguigu.gmall.search.pojo.SearchResponseVo;
import com.atguigu.gmall.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Date 2021/7/2 10:53
 * @Description TODO
 */
//@RestController
@Controller
@RequestMapping("search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @GetMapping
    public String search(SearchParamVo paramVo, Model model) {
      SearchResponseVo responseVo =  this.searchService.search(paramVo);
      model.addAttribute("response", responseVo);
      model.addAttribute("searchParam", paramVo);
        return "search";
    }

//    @GetMapping
//    public ResponseVo<SearchResponseVo> search(SearchParamVo paramVo) {
//      SearchResponseVo responseVo =  this.searchService.search(paramVo);
//        return ResponseVo.ok(responseVo);
//    }

}
